
package com.jf.cloud.multishop.feign;

import com.jf.cloud.api.multishop.feign.ShopWalletLogFeignClient;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.multishop.bo.mongo.MongoShopWalletLogBO;
import com.jf.cloud.multishop.constant.ShopWalletChangeReason;
import com.jf.cloud.multishop.service.ShopWalletLogService;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author zz
 * @date 2022/6/30 16:55
 */
@RestController
@Hidden
public class ShopWalletLogFeignController implements ShopWalletLogFeignClient {

    @Autowired
    private ShopWalletLogService shopWalletLogService;


    @Override
    public ServerResponseEntity<Long> getPayAmount(Long shopWalletLogId) {
        MongoShopWalletLogBO shopWalletLog = shopWalletLogService.getByWalletLogId(shopWalletLogId);
        return ServerResponseEntity.success(shopWalletLog.getShopChangeAmount());
    }

    @Override
    public ServerResponseEntity<Integer> getIsPay(Long shopWalletLogId) {
        MongoShopWalletLogBO shopWalletLog = shopWalletLogService.getByWalletLogId(shopWalletLogId);
        return ServerResponseEntity.success(Objects.equals(ShopWalletChangeReason.SUCCESS_RECHARGE.value(), shopWalletLog.getReason()) ? 1 : 0);
    }

//    @Override
//    public ServerResponseEntity<Integer> getShopBalancePayIsPay(Long orderId) {
//        List<MongoShopWalletLogBO> mongoShopWalletLogList = shopWalletLogService.getByOrderId(orderId);
//        return ServerResponseEntity.success(CollectionUtils.isNotEmpty(mongoShopWalletLogList) ? 1 : 0);
//    }
}
